<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/themes/icon.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>

<script type="text/javascript" charset="gbk" src="${pageContext.request.contextPath}/static/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="gbk" src="${pageContext.request.contextPath}/static/ueditor/ueditor.all.min.js"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="gbk" src="${pageContext.request.contextPath}/static/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">

	function submitData(){
		var title=$("#title").val();//标题
		var typeId=$("#typeId").combobox("getValue");//类型
		var state=$("#state").combobox("getValue");//状态
		var orUrl=$("#orUrl").val();//来源
		var tags=$("#tags").val();//标签
		var author=$("#author").val();//作者
		var img=$("#img").val();//作者
		var crawlerDate=$("#crawlerDate").datebox("getValue");//定时
		var content=UE.getEditor('editor').getContent();//内容
		var summary=UE.getEditor('editor').getContentTxt().substr(0,155);//摘抄
	
		$.post("${pageContext.request.contextPath}/admin/article/save.do",{'title':title,'arcType.id':typeId,'author':author,'state':state,'img':img,'orUrl':orUrl,'crawlerDate':crawlerDate,'tags':tags,'content':content,'summary':summary},function(result){
			if(result.success){
				alert("帖子发布成功！");
				resetValue();
			}else{
				alert("帖子发布失败！");
			}
		},"json");
		
	}
	
	
	function resetValue(){
		$("#title").val("");
		$("#typeId").combobox("setValue","-1");
		$("#state").combobox("setValue","-1");
		$("#orUrl").val("");
		$("#crawlerDate").datebox("setValue","");
		$("#tags").val("");
		UE.getEditor('editor').setContent("");
	}

</script>
<title>帖子添加页面</title>
</head>
<body style="margin: 10px">
<div id="p" class="easyui-panel" title="编写帖子" style="padding: 10px">
 	<table cellspacing="10px">
   		<tr>
   			<td width="80px">博客标题： </td>
   			<td><input type="text" id="title" name="title" style="width: 400px;"/></td>
   		</tr>
   		<tr>
   			<td>帖子类别：</td>
   			<td>
   				<select class="easyui-combobox" style="width: 154px" id="typeId" name="arcType.id" editable="false" panelHeight="auto" >
					<option value="-1">请选择帖子类别...</option>	
				    <c:forEach var="arcType" items="${arcTypeList }">
				     <option value="${arcType.id }">${arcType.typeName }</option>
				    </c:forEach>			
                </select>
                &nbsp;&nbsp;&nbsp;&nbsp;
   				 帖子状态： 
   				<select class="easyui-combobox" style="width: 154px" id="state" name="state" editable="false" panelHeight="auto" >
			     	<option value="1" selected="selected">已发布</option>			
				    <option value="0">未发布</option>
				    <option value="2">置顶</option>
                </select>
   			</td>
   		</tr>
   		<tr>
   			<td>Tag标签：</td>
   			<td><input type="text" id="tags" name="tags" style="width: 400px;"/>&nbsp;&nbsp;(多个Tag之间用空格隔开)</td>
   		</tr>
   		<tr>
   			<td valign="top">帖子内容：</td>
   			<td width="900px">
				   <script id="editor" type="text/plain" style="width:100%;height:500px;"></script>
   			</td>
   		</tr>
   		<tr>
   			<td> <input type="text" value="${currentUser.userName}" name="author" id="author" style="display: none;" disabled="disabled"> </td>
   			<td>
   				<br/> <br/> <hr>
   				 定时发布：  <input type="text" id="crawlerDate" name="crawlerDate" class="easyui-datetimebox"/>
   				<br/> <br/> <hr>
   				 来源地址：   <input type="text" id="orUrl" name="orUrl" style="width: 400px;"/> 
   				 封页图片：   <input type="text" id="img" name="img" style="width: 400px;"/> 
   			</td>
   			<td align="right">
   			  <a href="javascript:submitData()" class="easyui-linkbutton" data-options="iconCls:'icon-submit'">发布博客</a> 
   			</td>
   		</tr>
   	</table>
 </div>
 
 <script type="text/javascript">

    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');


</script>
</body>
</html>